<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace plugins\qq_login;

use cmf\lib\Plugin;

class QqLoginPlugin extends Plugin
{

    public $info = [
        'name'        => 'QqLogin',
        'title'       => 'QQ登录',
        'description' => 'QQ登录',
        'status'      => 1,
        'author'      => 'ThinkCMF',
        'version'     => '1.0'
    ];

    public $hasAdmin = 0;//插件是否有后台管理界面

    // 插件安装
    public function install()
    {
        $thirdPartyLoginOption = cmf_get_option('third_party_login');
        if (empty($thirdPartyLoginOption)) {
            $thirdPartyLoginOption = [];
        }

        $thirdPartyLoginOption['QqLogin'] = [
            'name'     => 'QQ',
            'key'      => 'qq',
            'callback' => [
                'login'   => '',
                'binding' => ''
            ],
            'logo'     => 'plugins/qq_login/images/qq.png'
        ];

        cmf_set_option('third_party_login', $thirdPartyLoginOption, true);
        return true;//安装成功返回true，失败false
    }

    // 插件卸载
    public function uninstall()
    {
        $thirdPartyLoginOption = cmf_get_option('third_party_login');
        if (empty($thirdPartyLoginOption)) {
            $thirdPartyLoginOption = [];
        }

        unset($thirdPartyLoginOption['QqLogin']);

        cmf_set_option('third_party_login', $thirdPartyLoginOption);
        return true;//卸载成功返回true，失败false
    }

}